package community.infrastructure.repository;

import community.domain.model.Comment;
import community.domain.repository.CommentRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
@RequiredArgsConstructor
public class CommentRepositoryImpl implements CommentRepository {

    private final JpaCommentRepository jpaCommentRepository;

    @Override
    public Comment save(Comment comment) {
        return jpaCommentRepository.save(comment);
    }

    @Override
    public Optional<Comment> findById(Long id) {
        return jpaCommentRepository.findById(id);
    }

    @Override
    public List<Comment> findByPostId(Long postId) {
        return jpaCommentRepository.findByPostId(postId);
    }

    @Override
    public List<Comment> findByParentCommentId(Long parentId) {
        return jpaCommentRepository.findByParentCommentId(parentId);
    }

    @Override
    public void deleteById(Long id) {
        jpaCommentRepository.deleteById(id);
    }
}
